import 'package:flutter/material.dart';
import 'package:shenling/pages/task/components/completed.dart';
import 'package:shenling/pages/task/components/onWay.dart';
import 'package:shenling/pages/task/components/waiting.dart';
import 'package:shenling/utils/http.dart';

class TaskPage extends StatefulWidget {
  const TaskPage({super.key});

  @override
  State<TaskPage> createState() => _TaskPageState();
}

class _TaskPageState extends State<TaskPage> {
  List goodsList = [
    {
      "created": "2022.05.04",
      "enablePickUp": true,
      "endAddress": "广州广州广州广州广州广州广州",
      "planArrivalTime": "2025.05.03",
      "startAddress": "顺德顺德顺德顺德顺德顺德顺德顺德顺德顺德顺德顺德顺德顺德顺德顺德",
      "status": "1",
      "transportTaskId": "xxx123456"
    },
    {
      "created": "2022.05.04",
      "enablePickUp": true,
      "endAddress": "佛山佛山佛山佛山佛山佛山佛山佛山佛山佛佛山佛山佛山佛山佛山",
      "planArrivalTime": "2025.05.03",
      "startAddress": "顺德顺德顺德顺德顺德顺德顺德顺德顺德顺德顺德顺德顺德顺德顺德顺德",
      "status": "2",
      "transportTaskId": "xxx123456"
    },
    {
      "created": "2022.05.04",
      "enablePickUp": true,
      "endAddress": "开平开平开平开平开平开平开平开平开平开平开平开平开平开平开平开平开平开平",
      "planArrivalTime": "2025.05.03",
      "startAddress": "顺德顺德顺德顺德顺德顺德顺德顺德顺德顺德顺德顺德顺德顺德顺德顺德",
      "status": "3",
      "transportTaskId": "xxx123456"
    }
  ];

  // 调接口获取订单数据
  void getGoodsList() async {
    // 准备参数
    var params = {
      "page": 1,
      "pageSize": 10,
      "status": 1,
    };
    // print('111');
    var res = await dioHttp.get('/driver/tasks/list', params: params);
    print(res);

    // var res = await request.get('/api/goods/list');
    // setState(() {
    //   goodsList = res.data;
    // });
  }

  @override
  void initState() {
    super.initState();
    // getGoodsList();
  }

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
        length: 3,
        child: Scaffold(
          appBar: AppBar(
            backgroundColor: Colors.white,
            title: TabBar(
                labelColor: Colors.black,
                indicatorColor: Colors.red,
                dividerColor: Colors.transparent,
                tabs: [
                  Container(
                    padding: const EdgeInsets.only(bottom: 8),
                    child: const Text('待提货'),
                  ),
                  Container(
                    padding: const EdgeInsets.only(bottom: 8),
                    child: const Text('在途'),
                  ),
                  Container(
                    padding: const EdgeInsets.only(bottom: 8),
                    child: const Text('已完成'),
                  ),
                ]),
          ),
          body: TabBarView(
            children: [
              Waiting(
                goodsList: goodsList,
              ),
              OnWay(
                goodsList: goodsList,
              ),
              Completed(
                goodsList: goodsList,
              ),
            ],
          ),
        ));
  }
}
